<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'ratesearch';
$delete = $base_url;
$delete['action'] = 'ratedel';
$add = $base_url;
$add['action'] = 'rateadd';
$import = $base_url;
$import['action'] = 'import';
?>
<script>
/**
 * 获取页面选中input框的ID字符串连接
 */
function get_selecteds(id)
{
	var list = document.getElementsByName(id);
	var values='';
    for(var i=0;i<list.length;i++)
    {
        if(list[i].checked)
        {
            if(values=='')
            {
            	values=list[i].value;
			}else
			{
				values=values+','+list[i].value;
				}
        	continue;
        }
    }
    return values;
}

function piliang(rategroupid)
{
	var values=get_selecteds('ids');
	var bili = prompt("输入调整倍数0-N,如1.5(提价1.5倍)","");
	if (values && bili)
	{
		$.post('<?php echo url("rate/rateset")?>',{ids: values, bili: bili, rategroupid: rategroupid},function(data){alertMsg.correct(data);});
		
			}
	
	}

</script>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<input type="hidden" name="agent_id" value="<?php echo isset($param['agent_id'])?$param['agent_id']:$Content->get('agent_id')?>">
	<div class="searchBar">
	<div class="subBar"><font color="red">当前位置：<?php echo Rategroup::get_rategroupname(isset($param['rategroupid'])?$param['rategroupid']:$Content->get('rategroupid'))?> 的费率列表</font></div>
		<ul class="searchContent">
			
			<li>
				<label>拨号前缀：</label>
				<input type="text" name="prefix" value="<?php echo isset($param['prefix'])?$param['prefix']:'';?>"/>
				<input type="hidden" name="_querymethod[prefix]" value="like">
				<input type="hidden" name="rategroupid" value="<?php echo isset($param['rategroupid'])?$param['rategroupid']:$Content->get('rategroupid');?>"/>
			</li>
			
		</ul>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			<li><a title="确认删除选中的数据?" target="selectedTodo" rel="ids" href="<?php echo url($delete)?>" class="delete"><span>批量删除</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($add)?>/id/{id}" target="dialog" height="500" warn="请选择一个产品"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($add,array('agent_id'=>isset($param['agent_id'])?$param['agent_id']:$Content->get('agent_id'),'rategroupid'=>isset($param['rategroupid'])?$param['rategroupid']:$Content->get('rategroupid')))?>" target="dialog" rel="添加代理费率" height="500" warn="请选择一个产品"><span>添加</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="piliang(<?php echo isset($param['rategroupid'])?$param['rategroupid']:$Content->get('rategroupid')?>)"  ><span>批量改价</span></a></li>
			<li class="line">line</li>
									<li><a class="edit" href="<?php echo url('rate/agent')?>" target="navTab" ><span>返回</span></a></li>
		</ul>
	</div>
	<table class="table" width="1200" layoutH="158">
		<thead>
			<tr>
				<th width="5%"><input type="checkbox" group="ids" name="ids" class="checkboxCtrl"></th>
				<th width="5%">ID</th>
				<th width="5%" orderField="rategroupname" >拨号前缀</th>
				<th width="5%" >备注</th>
				<th width="5%" >默认费率</th>
				<th width="10%" >计费时间段(时)</th>
				<th width="10%" >计费周期(秒)</th>
				<th width="10%">创建时间</th>
				<th width="20%" align="center">选项</th>
				
			</tr>
		</thead>
		<tbody>
		
			<?php foreach ($item as $k=>$v):?>
			<?php if($v->prefix == '8')continue;?>
			<tr target="id" rel="<?php echo $v->id?>">
				<td><input name="ids" value="<?php echo $v->id?>" type="checkbox"></td>
				<td><?php echo $v->id;?></td>
				<td><?php echo $v->prefix?></td>
				<td><?php echo $v->prefixname;?></td>
				
				<td><?php 
				echo sprintf('%f',$v->rateprice)
				?></td>
				<td><?php echo $v->start_hour.'点'.'-'.$v->end_hour.'点';?></td>
				<td><?php echo $v->payunitsecond;?> </td>
				
				<td><?php echo $v->createtime;?></td>
			
				<td>
					<a href="<?php echo url('rate/rateadd',array('id'=>$v->id),null,array('mode'=>'standard'));?>" target="dialog" rel="费率列表">费率管理</a>
				</td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>